package com.ruoyi.vplat.dao;

import java.util.List;
import java.util.Map;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ruoyi.vplat.mapper.VplatGatewayMapper;
import com.ruoyi.vplat.domain.VplatGateway;

/**
 * 网关Dao层
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@Repository
public class VplatGatewayDao
{
    @Autowired
    private VplatGatewayMapper vplatGatewayMapper;

    /**
     * 查询网关
     * 
     * @param id 网关主键
     * @return 网关
     */
    public VplatGateway selectById(String id)
    {
        return vplatGatewayMapper.selectById(id);
    }

    /**
     * 查询网关列表
     * 
     * @param vplatGateway 网关
     * @return 网关
     * @throws Exception
     */
    public List<Map<String, Object>> queryList(Map<String, Object> param) throws Exception
    {
        List<Map<String, Object>> list = vplatGatewayMapper.queryList(param);
        //BeanUtils.caseFormat(list); 在Mybatis拦截器插件中统一处理
		return list;
    }
    
    /**
     * 查询网关列表
     * 
     * @param vplatGateway 网关
     * @return 网关
     */
    public List<VplatGateway> selectList(VplatGateway vplatGateway)
    {
        return vplatGatewayMapper.selectList(vplatGateway);
    }

    /**
     * 新增网关
     * 
     * @param vplatGateway 网关
     * @return 结果
     */
    public int insert(VplatGateway vplatGateway)
    {
        vplatGateway.setCreateTime(DateUtils.getNowDate());
        return vplatGatewayMapper.insert(vplatGateway);
    }

    /**
     * 修改网关
     * 
     * @param vplatGateway 网关
     * @return 结果
     */
    public int update(VplatGateway vplatGateway)
    {
        vplatGateway.setUpdateTime(DateUtils.getNowDate());
        return vplatGatewayMapper.update(vplatGateway);
    }

    /**
     * 批量删除网关
     * 
     * @param ids 需要删除的网关主键
     * @return 结果
     */
    public int deleteByIds(String[] ids)
    {
        return vplatGatewayMapper.deleteByIds(ids);
    }

    /**
     * 删除网关信息
     * 
     * @param id 网关主键
     * @return 结果
     */
    public int deleteById(String id)
    {
        return vplatGatewayMapper.deleteById(id);
    }

	public VplatGateway selectByName(String name) {
		VplatGateway example = new VplatGateway();
		example.setName(name);
		List<VplatGateway> list = vplatGatewayMapper.selectList(example);
		return list != null && list.size() > 0 ? list.get(0) : null;
	}

	public int downAll() {
		return vplatGatewayMapper.downAll();
	}
}
